package com.jobsika.client.register;

import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.FlexTable;
import com.google.gwt.user.client.ui.TextBox;
import com.jobsika.domain.RPCUser;

public class Register extends Composite {
	private FlexTable skeleton;
	private TextBox firstNameBox;
	private TextBox lastNameBox;
	private TextBox emailBox;
	private TextBox birthdayBox;
	private TextBox collegeBox;
	private TextBox employerBox;
	public	Button submit;
	
	public Register() {
		skeleton = new FlexTable();
		firstNameBox = new TextBox();
		lastNameBox = new TextBox();
		emailBox = new TextBox();
		birthdayBox = new TextBox();
		collegeBox = new TextBox();
		employerBox = new TextBox();
		submit = new Button("Submit");
		
		skeleton.setHTML(0, 0, "First Name:");
		skeleton.setHTML(1, 0, "Last Name:");
		skeleton.setHTML(2, 0, "Email:");
		skeleton.setHTML(3, 0, "Birthday:");
		skeleton.setHTML(4, 0, "College/University::");
		skeleton.setHTML(5, 0, "Employer:");
		skeleton.setWidget(0, 1, firstNameBox);
		skeleton.setWidget(1, 1, lastNameBox);
		skeleton.setWidget(2, 1, emailBox);
		skeleton.setWidget(3, 1, birthdayBox);
		skeleton.setWidget(4, 1, collegeBox);
		skeleton.setWidget(5, 1, employerBox);
		skeleton.setWidget(6, 1, submit);
		
		skeleton.setStyleName("registerForm");
		submit.addStyleName("registerForm-submit");
		this.initWidget(skeleton);
	}
	
	public RPCUser getUser() {
		RPCUser user = new RPCUser();
		user.setFirstName(firstNameBox.getText());
		user.setLastName(lastNameBox.getText());
		user.setEmail(emailBox.getText());
		user.setSchool(collegeBox.getText());
		user.setEmployer(employerBox.getText());
		return user;
	}
	
	public void setEmail(String email) {
		emailBox.setText(email);
		emailBox.setEnabled(false);
	}
	
}
